<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Troy Inaction</title>

<script src="http://code.jquery.com/jquery-latest.js"></script>	
<script src="slider.js" type="application/javascript"></script>
<script src="test.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="slider.css" />

<script language="Javascript"> 

var ind = 0;
var ind3 = 0;
var indCat = 0;

function addElementRPI() {
  var ni = document.getElementById('RPI-box');
  var numi = document.getElementById('theValue');
  var num = (document.getElementById('theValue').value -1)+ 2;
  numi.value = num;
  var newdiv = document.createElement('div');
  var divIdName = 'my'+num+'Div';
  newdiv.setAttribute('id',divIdName);
  newdiv.setAttribute('class','RPI-event');
  newdiv.innerHTML = '<h2>' + events.bwEventList.events[ind].summary + '</h2><p>Date: ' + events.bwEventList.events[ind].start.longdate + '<br />Time: ' + events.bwEventList.events[ind].start.time + '<br />Location: ' + events.bwEventList.events[ind].location.address + '</p>';
  
  ni.appendChild(newdiv);
  ind++;
}
function addElement(category) {
	var cat = category;
	var found = 0;
  var ni = document.getElementById('Troy-box');
  var newdiv = document.createElement('div');
  var divIdName = 'my'+indCat+'DivCat';
  newdiv.setAttribute('id',divIdName);
  newdiv.setAttribute('class','Troy-event');

  while (found == 0 && ind3 < 20) {
		if (events.bwEventList.events[ind3].categories[0] == cat || events.bwEventList.events[ind3].categories[1] == cat) {
			
			newdiv.innerHTML = '<h2>' + events.bwEventList.events[ind3].summary + '</h2><p>Date: ' + events.bwEventList.events[ind3].start.longdate + '<br />Time: ' + events.bwEventList.events[ind3].start.time + '<br />Location: ' + events.bwEventList.events[ind3].location.address + '</p>';
			
			found = 1;
		}
		ind3++;
	}
	if (found == 1) {
		ni.appendChild(newdiv);
		indCat++;
	}
	found = 0;
}
function ChangeScroller(category){
	var div;
	while(indCat > 0) {
		 div = 'my'+indCat+'DivCat';
		removeElement(div);
		indCat--;
	}
	
}
function removeElement(divNum) {
  var d = document.getElementById('Troy-box');
  var olddiv = document.getElementById(divNum);
  d.removeChild(olddiv);
}
</script>
</head>

<body>

<div id="RPI" class="bar">
  <div id="RPI-scroller" class="scroller">
    <div id="RPI-box" class="box">
		<input type="hidden" value="0" id="theValue" />
		<script language="Javascript">
			var i = 0;
			for (i=0;i<=4;i=i+1) {
				addElementRPI();
			}
		</script>
    </div>
  </div>
  <div id="RPI-previous" class="prev"></div>
  <div id="RPI-next" class="next"></div>
</div>

<br />

<div id="Troy" class="bar">
  <div id="Troy-scroller" class="scroller">
    <div id="Troy-box" class="box">
		<script language="Javascript">
			var j = 0;
			for (j=0;j<=4;j=j+1) {
				addElement('Other Events');
			}
		</script>
    </div>
  </div>
  <div id="Troy-previous" class="prev"></div>
  <div id="Troy-next" class="next"></div>

</div>
  <form name="form3">
		<input type="button" value="Open Houses"
		onClick="ChangeScroller('Open Houses');">
	</form>

</body>
</html>
